import request from '@/utils/request.js'

// 登录发号码
export function getCode (modile) {
  return request({
    url: '/v1_0/sms/codes/' + modile
  })
}
/**
 * // 用户验证
 * @param {*} data
 * @returns
 */
export function login (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data
  })
}
/* 获取用户信息 */
export function getUserSelfInfo () {
  return request({
    url: '/v1_0/user',
    method: 'GET'
  })
}

/* 获取全部的频道O */
export function getUserSelfChannels () {
  return request({
    url: '/v1_0/user/channels'
  })
}
/**
 *封装添加频道 参数是： {
  id
  seq
}
 */
export function addUserChannelItem (channel) {
  return request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: [channel]
    }
  })
}
//  删除接口
export function deleteSpecifyDelete (id) {
  return request({
    url: '/v1_0/user/channels/' + id,
    method: 'DELETE'
  })
}
//  关注用户接口
export function follUser (target) {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target: target
    }
  })
}
// 取消关注接口
export function deletUser (target) {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'DELETE'
  })
}

/**
 *
 * @param {*} target 收藏添加
 */
export function AddCollection (target) {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target: target
    }
  })
}
/**
 *
 * @param {*} target 取消收藏
 * @returns
 */
export function deletCollection (target) {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'DELETE'
  })
}
/**
 *
 * @param {*} params 获取评论
 * @returns
 */
export function getComment (params) {
  return request({
    url: '/v1_0/comments',
    method: 'GET',
    params
  })
}
export function getprofile () {
  return request({
    url: '/v1_0/user/profile',
    method: 'GET'
  })
}
/**
 *
 * @param {*} data 修改用户信息
 * @returns
 */
export function patchuSerProfile (data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}

export function updateUserPhobo (data) {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}
